/**
 * 移动端菜单权限API
 * 
 * 权限控制粒度简化：
 * - 提供菜单权限相关接口
 * - 移除按钮权限相关接口
 * 
 * @author Wu.Liang
 * @date 2025-07-01
 * @updated 2025-07-02 - 权限控制粒度简化
 * @version 1.0.0
 */

import request from '@/api/request'

/**
 * 获取用户菜单权限列表
 * @returns {Promise<Object>}
 */
export function getMenuPermissions() {
  return request.get('/api/user/permissions/menu')
}

/**
 * 获取用户菜单权限树
 * @returns {Promise<Object>}
 */
export function getMenuPermissionTree() {
  return request.get('/api/user/permissions/menu/tree')
}

/**
 * 检查用户是否有指定菜单权限
 * @param {string} menuCode 菜单编码
 * @returns {Promise<Object>}
 */
export function checkMenuPermission(menuCode) {
  return request.get(`/api/user/permissions/menu/check/${menuCode}`)
}

/**
 * 批量检查菜单权限
 * @param {Array<string>} menuCodes 菜单编码数组
 * @returns {Promise<Object>}
 */
export function checkMenuPermissions(menuCodes) {
  return request.post('/api/user/permissions/menu/check/batch', { menuCodes })
}

/**
 * 获取用户权限信息
 * @returns {Promise<Object>}
 */
export function getUserPermissions() {
  return request.get('/api/user/permissions')
}

/**
 * 刷新用户权限缓存
 * @returns {Promise<Object>}
 */
export function refreshPermissionCache() {
  return request.post('/api/user/permissions/refresh')
}

/**
 * 权限API统一导出
 */
export default {
  getMenuPermissions,
  getMenuPermissionTree,
  checkMenuPermission,
  checkMenuPermissions,
  getUserPermissions,
  refreshPermissionCache
} 